﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Timers;
using System.Configuration;

namespace TicketProcessingService
{
    public partial class TicketProcessor : ServiceBase
    {
        public TicketProcessor()
        {
            InitializeComponent();
        }
        Timer timer1 = new Timer(Convert.ToDouble(60000));
        int ctr = 1;
        protected override void OnStart(string[] args)
        {
            timer1.Elapsed += timer1_Elapsed;
            timer1.Start();
        }

        void timer1_Elapsed(object sender, ElapsedEventArgs e)
        {
            int minutes = Convert.ToInt32(ConfigurationManager.AppSettings.Get("intMinutes").ToString());
            if (ctr == minutes)
            {
               ProcessTickets procTicket = new ProcessTickets();
               procTicket.NotifyDelays();
               SendEMail EmailSender = new SendEMail();
               EmailSender.SendMail();
               ctr = 1;
            }
            else
                ctr++;
        }

        protected override void OnStop()
        {
            
            timer1.Stop();
        }


     }
}
